"use strict";

$(function(){
    // 子页面设置父页面iframe高度
    if(window.parent.setiframeHeight){
        var ht=$("#container").height();
		ht=ht>800?ht:800;
        window.parent.setiframeHeight(ht);
    }

    var vm=new Vue({
     el: '#studentcontainer',
     data:{
        lessonlist:[]
	 },
	 methods:{
		foamartList:function (arr){
			// 数组重分类和计数以符合td rowspan
			var uniqueIds=new Set();//es6
			var count=1;
			for(var i in arr){
				var item=arr[i];
				var uid=item.id+','+item.phase;
				if(i>0){
					if(uniqueIds.has(uid)){
						count++;
					}
					else{
						let theInex=i-count;
						arr[theInex].rowspan=count;
						count=1;
						uniqueIds.add(uid);
					}
				}
				else{
					// 第0个不参与比较
					uniqueIds.add(uid);
				}
			}
			// 还要补上最后一组的计数
			arr[arr.length-count].rowspan=count;
			return arr;
			
		}
	},
    mounted :function(){
       var  url='studentscore/'+UserID;//UserID
            $.get(url,function(data){
                if(data){ this.lessonlist=this.foamartList(data)}     
            }.bind(this))
    }
})
});

